import java.sql.SQLOutput;
import java.util.Random;
import java.util.Scanner;

public class ball {
    //1步
    //生成中奖的球号码
    //6个红球号码(1~33)
    //1个蓝球号码(1~16)
    //2步
    //用户输入选择自己的球号码
    //3步
    //判断用户是否中奖
    public static void main(String[] args) {
        int[] arr = new int[7];
        int[] NewArr = new int[7];
        Random r = new Random();
        //存入6个随机的红球号码
        for (int i = 0; i < 6; ) {
            int number = r.nextInt(33) + 1;
            if (!judge(NewArr, number)) {
                NewArr[i] = number;
                i++;
            }
        }
        //存入随机的蓝球号码
        for (int i = 0; i < 1; i++) {
            int number2 = r.nextInt(16) + 1;
            NewArr[6] = number2;
        }
        //已经完成了中奖号码的随机生成
        System.out.println("本次中奖的号码为:");
        for (int i = 0; i < NewArr.length; i++) {
            System.out.print(NewArr[i] + " ");
        }
        System.out.println();
        System.out.println("请输入您要选择的号码" + " " + "6个1~33的数" + " " + "一个1~16的数");
        Scanner sc = new Scanner(System.in);
        int[] ScArr = new int[7];
        for (int i = 0; i < 6; ) {
            System.out.println("您输入的第" + (i + 1) + "个数字是:");
            int count = sc.nextInt();
            if (count >= 1 && count <= 33) {
                if (!judge(ScArr, count)) {
                    ScArr[i] = count;
                    i++;
                } else {
                    System.out.println("重复数字");
                }

            } else {
                System.out.println("无效数字,请重新输入");
            }

        }
        for (int i = 0; i < 1; ) {
            System.out.println("您输入的第7个数字是:");
            int count = sc.nextInt();
            if (count >= 1 && count <= 16) {
                ScArr[6] = count;
                i++;
            } else {
                System.out.println("无效数字");
            }

        }

        for (int i = 0; i < ScArr.length; i++) {
            System.out.print(ScArr[i] + " ");
        }
        System.out.println();
        int RedNumber = judgee(NewArr, ScArr);
        System.out.println(RedNumber+"<<<<<<<<<<");
        //boolean BlueNumber = aBoolean(NewArr, ScArr);
        //EndJudge(RedNumber, BlueNumber);

    }

    //判断中了几个蓝球
    public static int judgee(int[] Newarr, int[] ScArr) {
        int sum = 0;
        for (int i = 0; i < Newarr.length - 1; i++) {
            for (int i1 = 0; i1 < ScArr.length - 1; i1++) {
                if (ScArr[i1] == Newarr[i]) {
                    sum++;
                }
            }
        }
        return sum;
    }

    public static boolean aBoolean(int[] ScArr, int[] NewArr) {
        if ((ScArr[6] == NewArr[6])) {
            return true;
        }
        return false;
    }

    //中了几等奖
    public static void EndJudge(int sum, boolean BlueJudge) {
        if (sum == 6 && BlueJudge == true) {
            System.out.println("中了1000万");
        } else if (sum == 6 && BlueJudge == false) {
            System.out.println("中了500万");
        } else if (sum == 5 && BlueJudge == true) {
            System.out.println("中了3000元");
        } else if (sum == 5 && BlueJudge == false) {
            System.out.println("中200元");
        } else if (sum == 4 && BlueJudge == true) {
            System.out.println("中200");
        } else if (sum == 4 && BlueJudge == false) {
            System.out.println("中10");
        } else if (sum == 3 && BlueJudge == true) {
            System.out.println("中10");
        } else if (sum == 2 && BlueJudge == true) {
            System.out.println("中5");
        } else if (sum == 1 && BlueJudge == true) {
            System.out.println("中5");
        } else if (sum == 0 && BlueJudge == true) {
            System.out.println("中5");
        }
    }

    //因为红球内号码不能重复,写一个方法判断红球内数字是否重复
    public static boolean judge(int[] arr, int number) {
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] == number) {
                return true;
            }
        }
        return false;
    }
}
